package com.aps.api;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import com.aps.entity.ResultEntity;
import com.aps.entity.domain.dish.DishProcess;
import com.aps.page.BaseQuery;
import com.aps.service.IDishProcessService;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;

/**
 * @author liaoguangan
 * @description <>
 * @date 2018/4/9 16:00
 */
@RestController
@RequestMapping("/manage-api")
@Api(value = "manage-dish-process-api", description = "菜品工序管理接口")
public class DishProcessApi {

    @Autowired
    private IDishProcessService dishProcessService;

    @RequestMapping(value = "/list-process", method = RequestMethod.POST)
    @ApiOperation("查询工序列表")
    public ResultEntity listProcess(@RequestBody BaseQuery baseQuery) {
        return new ResultEntity(dishProcessService.list(baseQuery));
    }

    @RequestMapping(value = "/process", method = RequestMethod.POST)
    @ApiOperation("增加工序")
    public ResultEntity add(@RequestBody DishProcess dishProcess) {
        return new ResultEntity(dishProcessService.add(dishProcess));
    }

    @RequestMapping(value = "/process/{id}", method = RequestMethod.DELETE)
    @ApiOperation("删除工序")
    public ResultEntity remove(@PathVariable("id") String id) {
        dishProcessService.remove(id);
        return new ResultEntity(true);
    }

    @RequestMapping(value = "/process", method = RequestMethod.PUT)
    @ApiOperation("更新工序")
    public ResultEntity update(@RequestBody DishProcess dishProcess) {
        return new ResultEntity(dishProcessService.update(dishProcess));
    }

    @RequestMapping(value = "/process/{id}", method = RequestMethod.GET)
    @ApiOperation("查询工序")
    public ResultEntity listProcess(@PathVariable("id") String id) {
        return new ResultEntity(dishProcessService.get(id));
    }
}
